package club.yuit.desktop.ui;

import javax.swing.border.LineBorder;
import javax.swing.plaf.UIResource;
import javax.swing.plaf.basic.BasicGraphicsUtils;
import java.awt.*;

/**
 * @author: yuit
 * @date: 2023/12/12 18:57
 */
public class CustomDashedBorder extends LineBorder  {
    public CustomDashedBorder(Color color) {
        super(color);
    }

    public CustomDashedBorder(Color color, int thickness)  {
        super(color, thickness);
    }

    public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
        Color oldColor = g.getColor();
        int i;

        g.setColor(lineColor);
        for(i = 0; i < thickness; i++)  {
            BasicGraphicsUtils.drawDashedRect(g, x+i, y+i, width-i-i, height-i-i);
        }
        g.setColor(oldColor);
    }
}